<?php


namespace Api\Controller;

use Think\Controller;

class PublicInfoController extends Controller
{

    function __construct()
    {
    }

    function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 获取运营工具中的信息
     */
    public function getPublicInfo()
    {
        $appid = I('appid', 0);
        if (!empty($appid)) {
//           获取运营工具的小程序信息 创建一个新表 将值分为type 三类
            $sql = "select t.* from cmf_mini_program_relation r left join cmf_mini_program_info t on t.id=r.tools_id
where r.appid='$appid' and r.status=1 and t.status=1 and t.type = 1
order by r.listorder desc";
            $miniProgramInfo = M()->query($sql);
//            获取运营工具公众号文章跳转
            $articleSql = "select r.listorder,a.* from cmf_mini_program_relation r left join cmf_mini_program_info a on a.id = r.tools_id
                           where r.appid = '$appid' and r.status = 1 and a.status = 1 and a.type = 2 order by r.listorder desc";
            $articleInfo = M()->query($articleSql);
//            获取运营工具图片
            $imgSql = "select r.listorder,a.* from cmf_mini_program_relation r left join cmf_mini_program_info a on a.id = r.tools_id
                       where r.appid = '$appid' and r.status = 1 and a.status = 1 and a.type = 3 order by r.listorder desc";
            $imgInfo = M()->query($imgSql);
            $data = array('miniProgramInfo' => $miniProgramInfo, 'articleInfo' => $articleInfo, 'imgInfo' => $imgInfo);
            $this->returnok($data, 'ok');
        } else {
            $this->returnerror('', '非法请求');
        }
    }


}


